<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../plugins/elementui/index.css">
</head>
<body>

<div id="app">
    <el-tree
            :data="treeData"
            show-checkbox
            node-key="id"
            default-expand-all
            :expand-on-click-node="false">
      <span class="custom-tree-node" slot-scope="{ node, data }">
        <span>{{ node.label }}</span>
        <span>
          <el-button
                  type="text"
                  size="mini"
                  @click="() => append(data)">
            Append
          </el-button>
          <el-button
                  type="text"
                  size="mini"
                  @click="() => remove(node, data)">
            Delete
          </el-button>
        </span>
      </span>
    </el-tree>

</div>

<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script>

    var vue = new Vue({
        el:"#app",
        data:{
            treeData:[
                {id:1,label:"一级菜单1",children:[
                        {id:11,label:"二级菜单1",children:[
                                {id:111,label:"三级菜单1"}
                            ]},
                        {id:12,label:"二级菜单2"},
                    ]},
                {id:2,label:"一级菜单2"},
                {id:3,label:"一级菜单3"},
            ]
        },
        methods:{
            append(data){
                console.log(data.id);//data.id 是下一级菜单的父id
            }
        }
    })

</script>
</body>
</html>
